<?php $auth=0; ?>
<?php include 'lib/includes.php';
//include 'lib/debug.php';?>
<?php include 'partials/header_menu.php'; ?>

<script src="ckeditor/ckeditor.js"></script>
<h3>&nbsp;&nbsp;Contact :</h3>
<br>
<form class="form-horizontal" method="POST">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-1 control-label">Destinataire</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail2" name="inputd" placeholder="Entrer votre email" value="" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-1 control-label">À</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" name="inputa" placeholder="Entrer email " value="<?php  echo $_GET['mail'] ?>">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-1 control-label">Cc</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail4" name="inputcc" placeholder="Entrer email " value="">
    </div>
  </div>
  <div class="form-group">
    <label for="object" class="col-sm-1 control-label">Objet</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputPassword3" name="inputob" placeholder="entrer votre objet">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-1 col-sm-10">
       <textarea name="editor1"  id="editor1" rows="10" cols="80">
        </textarea>
            <script>
                CKEDITOR.replace( 'editor1' );
            </script>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-1 col-sm-10">
      <button type="submit" name="submit" class="btn btn-success">Envoyer</button>
    </div>
  </div>
</form> 
<?php
if(isset($_POST['submit']))
{
$d=$_POST['inputd'];
$a=$_POST['inputa'];
$cc=$_POST['inputcc'];
$obj=$_POST['inputob'];
$mes= $_POST['editor1'];	
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com;';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = $a;                 // SMTP username
$mail->Password = 'a08482883';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to
$mail->From = $d;
$mail->FromName = 'Mailer';
//$mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
//$mail->addAddress('ellen@example.com');               // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC($cc);
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = $obj;
$mail->Body    = $mes;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
	?>
	
    <div id="messno" class="alert alert-danger" role="alert">
		<span class="alert-link"><?php echo 'Mailer Error: ' . $mail->ErrorInfo;?></span>
    </div>	
	<script>
	$('#messno').delay(1000).fadeOut("slow"); 
	</script>
	<?php
} else {
	?>
	<div id="messyes" class="alert alert-success" role="alert">
		<span class="alert-link">Message a été bien envoyé.</span>
    </div>	
	<script>
	$('#messyes').delay(1000).fadeOut("slow"); 
	</script>
	
<?php
}  
}
?>
<?php include 'partials/footer.php'; ?>
